class OliveCheatManager extends GameCheatManager;

var class<OlivePC_Watcher>  WatcherClass;
var OlivePC_Watcher			WatcherControllerRef;

exec function ToggleWatcher()
{
	local PlayerController PC;
	local OlivePC_Watcher WC;

	foreach WorldInfo.AllControllers(class'PlayerController', PC)
	{
		if ( PC.bIsPlayer && PC.IsLocalPlayerController() )
		{
			WC = OlivePC_Watcher(PC);
			if( WC != none && WC.OriginalControllerRef == none )
			{
				//wc are disabled, so we are looking for normal player controller
				continue;
			}
			break;
		}
	}

	if( WC != none && WC.OriginalControllerRef != none )
	{
		WC.DisableWatcher();
	}
	else if( PC != none )
	{
		EnableWatcher();
	}
}

function EnableWatcher()
{
	local Player P;
	local vector eyeLoc;
	local rotator eyeRot;
	local float CameraFOVAngle;

	P = Player;
	if( P!= none && Pawn != none && IsLocalPlayerController() )
	{
		CameraFOVAngle = GetFOVAngle();

		WatcherControllerRef = Spawn(WatcherClass);
		WatcherControllerRef.PlayerInput = none;
		WatcherControllerRef.OriginalPlayer = P;
		WatcherControllerRef.OriginalControllerRef = outer;

		GetPlayerViewPoint(eyeLoc,eyeRot);
		WatcherControllerRef.SetLocation(eyeLoc);
		WatcherControllerRef.SetRotation(eyeRot);

		P.SwitchController( WatcherControllerRef );
		//DebugCameraControllerRef.OnActivate( outer );

		// Make sure the camera gets created and set it up.
		WatcherControllerRef.GetPlayerViewPoint(eyeLoc,eyeRot);
		if ( WatcherControllerRef.PlayerCamera != None )
		{
			WatcherControllerRef.PlayerCamera.SetFOV( CameraFOVAngle );
			WatcherControllerRef.PlayerCamera.UpdateCamera(0.0);
		}
		else
		{
			WatcherControllerRef.SetFOV(CameraFOVAngle);
		}
	}
}

exec function SpawnRebundProj()
{
	local OliveProj_RebundGun EO;
	local vector SpawnLoc;
	local rotator SpawnRot;
	SpawnLoc = Location + vect(100.f, 100.f, 0.f);
	SpawnRot = rotator(Normal(vect(100.f, 100.f, 0.f)));
	EO = Spawn(class'OliveProj_RebundGun', , , SpawnLoc, SpawnRot);
	if( EO != None && !EO.bDeleteMe )
	{
		EO.Init( Normal(vect(45.f, 45.f, 0.f)) );
	}
	
}

DefaultProperties
{
	WatcherClass=class'OlivePC_Watcher'
}
